<?php
use \tpfcore\Core;
?>
<!doctype html>
<head>
		<meta charset="utf-8">
		<!-- Set render engine for 360 browser -->
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<!-- HTML5 shim for IE8 support of HTML5 elements -->
		<!--[if lt IE 9]>
			<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js">
			</script>
		<![endif]-->
		<link href="{$admin_assets_path}/css/theme.min.css" rel="stylesheet">
		<link href="{$admin_assets_path}/css/simplebootadmin.css" rel="stylesheet">
		<link href="{$admin_assets_path}/css/default.css" rel="stylesheet" />
		<link href="{$admin_assets_path}/css/font-awesome.min.css" rel="stylesheet" type="text/css">
		<style>
			.length_3{width: 180px;} form .input-order{margin-bottom: 0px;padding:3px;width:40px;}
			.table-actions{margin-top: 5px; margin-bottom: 5px;padding:0px;} .table-list{margin-bottom:
			0px;}
		</style>
		<!--[if IE 7]>
			<link rel="stylesheet" href="{$admin_assets_path}/css/font-awesome-ie7.min.css">
		<![endif]-->
		<script type="text/javascript">
			//全局变量
			var GV = {
				WEB_ROOT:"",
				DIMAUB: "/",
				JS_ROOT: "/theme/backend/assets/js/",
				TOKEN: ""
			};
		</script>
		<!-- Le javascript==================================================-
		-> <!-- Placed at the end of the document so the pages load faster -->
		<script src="{$admin_assets_path}/js/jquery.js"></script>
		<script src="{$admin_assets_path}/js/wind.js"></script>
		<script src="{$admin_assets_path}/js/bootstrap.min.js"></script>
		<script src="{$admin_assets_path}/kindeditor/kindeditor-min.js"></script>
		<link href="{$admin_assets_path}/kindeditor/themes/default/default.css" rel="stylesheet"/>
	</head>
<script>
	KindEditor.ready(function(K) {
		var uploadbutton = K.uploadbutton({
			button : K('#uploadButton')[0],
			fieldName : 'imgFile',
			url:"{:Core::addons_url('Slide://Slide/upload')}",
			afterUpload : function(data) {
				if (data.error === 0) {
					var url = K.formatUrl(data.url, 'absolute');
							K('#url').val(url);
							$('#show_thumb').attr('src',url).show();
						} else {
							alert(data.message);
						}
					},
					afterError : function(str) {
						alert('自定义错误信息: ' + str);
					}
			});
			uploadbutton.fileBox.change(function(e) {
			uploadbutton.submit();
		});
	});
</script>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('slide/Slide/index')}">幻灯片管理</a></li>
			{notempty name="list"}
			<li><a href="{:url('slide/Slide/add_edit')}">添加幻灯片</a></li>
			<li class="active"><a href="{:url('slide/Slide/add_edit',['id'=>$list[0]['id']])}">编辑幻灯片</a></li>
			{else/}
			<li class="active"><a href="{:url('slide/Slide/add_edit')}">添加幻灯片</a></li>
			{/notempty}
		</ul>
		<form method="post" class="form-horizontal js-ajax-form" action="">
			{notempty name="list"}
			<input type="hidden" name="id" value="{$list[0]->id}"/>
			{/notempty}
			<fieldset>
				<div class="control-group">
					<label class="control-label">分类</label>
					<div class="controls">
						<select name="cid">
							{foreach name="categorys" id="vo"}
							<option value="{$vo.id}" {notempty name="list"}{eq name="list[0]->cid" value="$vo.id"}selected="selected"{/eq}{/notempty}>{$vo.name}</option>
							{/foreach}
						</select>
						<span class="form-required">*</span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">标题</label>
					<div class="controls">
						<input type="text" name="name" value="{$list[0]->name|default=''}">
						<span class="form-required">*</span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">链接</label>
					<div class="controls">
						<input type="text" name="url" value="{$list[0]->url|default=''}">
						<span class="form-required">*</span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">缩略图</label>
					<div class="controls">
						<input class="ke-input-text" type="text" id="url" value="{$list[0]->pic|default=''}" name='pic' readonly="readonly" /> 
						<input type="button" id="uploadButton" value="上传缩略图" />
						{empty name="list"}
						<img src="{$list[0]->pic|default=''}" style="width:50px;height:50px; display:none;" id="show_thumb"/>
						{else}
						{notempty name="list[0]->pic"}
						<img src="{$list[0]->pic}" style="width:50px;height:50px;" id="show_thumb"/>
						{else/}
						<img src="{$list[0]->pic|default=''}" style="width:50px;height:50px; display:none;" id="show_thumb"/>
						{/notempty}
						{/empty}
						<span class="form-required">*</span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">幻灯片内容</label>
					<div class="controls">
						<textarea name="content" rows="5" cols="57">{$list[0]->content|default=''}</textarea>
						<span class="form-required">*</span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">描述</label>
					<div class="controls">
						<textarea name="des" rows="5" cols="57">{$list[0]->des|default=''}</textarea>
					</div>
				</div>
			</fieldset>
			<div class="form-actions">
				<button class="btn btn-primary js-ajax-button" type="button">确定操作</button>
				<a class="btn" href="javascript:history.back(-1);">返回</a>
			</div>
		</form>
	</div>
	<script src="{$admin_assets_path}/js/common.js"></script>
</body>
</html>